﻿
using System;
using WCF.Common.DAL;
namespace WCF.Common
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“Logger”。
    public class Logger : ILogger
    {
        LogObjectDAL logDal = null;
        public OperateResult Log(string user, string type, string appid, string content)
        {
            try
            {
                if (logDal == null) logDal = new LogObjectDAL();
            }
            catch (Exception ex)
            {
                return new OperateResult() { IsSuccess = false, Message = ex.Message };
            }
            try
            {
                return logDal.Insert(new LogObject()
                {
                    UserID = user,
                    Content = content,
                    Type = type,
                    Date = System.DateTime.Now,
                    Code = appid,
                });
            }
            catch (Exception ex)
            {
                return new OperateResult() { IsSuccess = false, Message = ex.Message };
            }
        }
    }
}
